package claybird.dao;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;


import claybird.dom.Handicap;
import claybird.dom.Person;
@Repository
@Transactional
@SuppressWarnings("unchecked")
public class HandicapDao extends BaseRepository<Handicap>{
	public Handicap findByYear(Short year,Person pers){
		if ( em.createQuery("select h from "+ Handicap.class.getName()+" h where h.year = :year and h.person = :person")
				.setParameter("year", year).setParameter("person", pers).getResultList().size()>0){
			
			return (Handicap)em.createQuery("select h from "+ Handicap.class.getName()+" h where h.year = :year and h.person = :person")
					.setParameter("year", year).setParameter("person", pers).getSingleResult();
		}
		return null;
    }
    
}
